package com.dcourseboard.controller;


import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.dcourseboard.dao.DcourseBoardDao;
import com.dcourseboard.domain.DcourseBoardCommand;


@Controller
public class DcourseReplyInsertBoardController {
	
	@Autowired
	private DcourseBoardDao dcourseBoardDao;
	
	@RequestMapping("/dcourseBoard/reply1.do")
	public ModelAndView replyok(HttpServletRequest req, HttpServletResponse res)throws Exception{
		System.out.println("6");
		String num = req.getParameter("num");
		String writer_name = req.getParameter("writer_name");
		String password = req.getParameter("password");
		String title = req.getParameter("title");
		String content = req.getParameter("content");
		String reply = req.getParameter("reply");
		String reply_step = req.getParameter("reply_step");
		String reply_level = req.getParameter("reply_level");
		String id = req.getParameter("id");
		String ip = req.getRemoteAddr();
		 DcourseBoardCommand  dcourseBoardCommand = new  DcourseBoardCommand(writer_name, password, title, content,id,ip );

		 dcourseBoardCommand.setNum(Integer.parseInt(num));
		 dcourseBoardCommand.setReply(Integer.parseInt(reply));
		 dcourseBoardCommand.setReply_level(Integer.parseInt(reply_level));
		 dcourseBoardCommand.setReply_step(Integer.parseInt(reply_step));

		 dcourseBoardDao.replyBoard(dcourseBoardCommand);
		 System.out.println("8");
		return new ModelAndView("redirect:/dcourseBoard/list.do");
		
	}
	
}
